export type ArticleInformation = {
	id: number;
	author: string;
	author_home_page?: string;
	title: string;
	content: string;
	cover?: string;
	date: string;
	update_time: string;
	publish_time: string;
	publisher_id: number;
	publisher: string;
	sort_id: number;
	sort_name: string;
};

export type Article = ArticleInformation & {
	view: number;
	contentData: ArticleContentData;
};

export enum ArticleContentDataType {
	Unknown = "unknown",
	HTML = "html",
	JSON = "json",
	Markdown = "markdown",
}

export enum ArticleContentDataVersion {
	V1 = "v1",
	V2 = "v2",
}

export type ArticleContentNodeV1 = {
	type: string;
	value: string | ArticleContentNodeV1[] | { [key: string]: string };
	alt?: string;
};
export type ArticleContentNode = Partial<Pick<ArticleContentNodeV1, "value">> &
	Omit<ArticleContentNodeV1, "value"> & {
		tagName: string | "#text";
		textContent?: string; // 文本内容
		// a 标签属性
		href?: string; // 链接的href
		// 图片属性
		src?: string; // 图片的src

		children?: ArticleContentNode[];
	};

export type ArticleContentData =
	| {
		type:
			| ArticleContentDataType.Markdown
			| ArticleContentDataType.HTML
			| ArticleContentDataType.Unknown;
		version?: ArticleContentDataVersion;
		content?: string;
	  }
	| {
		type: ArticleContentDataType.JSON;
		version?: ArticleContentDataVersion.V1;
		jsonVersion?: ArticleContentDataVersion.V1;
		content?: ArticleContentNodeV1[];
	  }
  	| {
      	type: ArticleContentDataType.JSON;
		version: ArticleContentDataVersion.V2;
		jsonVersion?: ArticleContentDataVersion.V2;
		content?: ArticleContentNode[];
    };
